<?php
/* Project Parasynthesis
*  Author: Fujiwara Sai
*  Usage: Parasy Static
*/

if (isset($_GET['type'])) {
	$type = strtolower(trim($_GET['type']));
} else {
	$type = 'css';
}

switch ($type) {
	default:
	case 'css':
		if (isset($_GET['filename'])) {
			$filename= strtolower(trim($_GET['filename']));
		}
		if(preg_match('/(style_)/i', $_SERVER['SCRIPT_URL'])) {
			$filedir = './forumdata/cache/';
			if(extension_loaded('zlib')){
				ob_start('ob_gzhandler');
			} 
			@header("Content-type: text/css");
			@readfile($filedir.$filename.'.css');
			if(extension_loaded('zlib')){
				ob_end_flush();
			}
		} else {
			$filedir = './templates/css/';
			if(extension_loaded('zlib')){
				ob_start('ob_gzhandler');
			} 
			@header("Content-type: text/css");
			@readfile($filedir.$filename.'.css');
			if(extension_loaded('zlib')){
				ob_end_flush();
			}
		}
	break;
	
	case 'scripts':
		if (isset($_GET['filename'])) {
			$filename= strtolower(trim($_GET['filename']));
		}
		$filedir = './include/javascript/';
		if(extension_loaded('zlib')){
			ob_start('ob_gzhandler');
		}
		@header("Content-type: text/javascript");
		@readfile($filedir.$filename.'.js');
		if(extension_loaded('zlib')){
			ob_end_flush();
		}
	break;
}

?>